# Contriburo: Łukasz Jendrysik <scadu@yandex.com>
# Contributor: Michael Mason <ms13sp@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=gnutls
pkgver=3.7.6
pkgrel=0
pkgdesc="TLS protocol implementation"
url="https://www.gnutls.org/"
arch="all"
license="LGPL-2.1-or-later"
checkdepends="diffutils datefudge"
makedepends="nettle-dev zlib-dev libtasn1-dev p11-kit-dev libunistring-dev texinfo"
subpackages="$pkgname-dbg $pkgname-doc $pkgname-dev $pkgname-utils $pkgname-c++:xx"
_v=${pkgver%.*}
case $pkgver in
*.*.*.*) _v=${_v%.*};;
esac
source="https://www.gnupg.org/ftp/gcrypt/gnutls/v$_v/gnutls-$pkgver.tar.xz
	skip-crq.patch
	tests-certtool.patch
	"

# Upstream Tracker: https://gnutls.org/security-new.html
# secfixes:
#   3.7.1-r0:
#     - CVE-2021-20231 GNUTLS-SA-2021-03-10
#     - CVE-2021-20232 GNUTLS-SA-2021-03-10
#   3.6.15-r0:
#     - CVE-2020-24659 GNUTLS-SA-2020-09-04
#   3.6.14-r0:
#     - CVE-2020-13777 GNUTLS-SA-2020-06-03
#   3.6.13-r0:
#     - CVE-2020-11501 GNUTLS-SA-2020-03-31
#   3.6.7-r0:
#     - CVE-2019-3836
#     - CVE-2019-3829
#   3.5.13-r0:
#     - CVE-2017-7507

build() {
	LIBS="-lgmp" ./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--disable-openssl-compatibility \
		--disable-rpath \
		--disable-static \
		--disable-guile \
		--disable-valgrind-tests
	make
}

check() {
	make check
}

package() {
	DESTDIR="$pkgdir" make -C "$builddir" install
}

utils() {
	license="GPL-3.0-or-later"
	pkgdesc="Command line tools for TLS protocol"
	mkdir -p "$subpkgdir"/usr/
	mv "$pkgdir"/usr/bin "$subpkgdir"/usr/
}

xx() {
	pkgdesc="The C++ interface to GnuTLS"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/lib*xx.so.* "$subpkgdir"/usr/lib/
}

sha512sums="
f872339df80ec31d292821ff00eaafbe50e0bd4cdbb86e21e4f78541cd0a26d843596d5e69c91de4db8ce7d027fc639ae6462b57d89fb116162ae63c5a97486a  gnutls-3.7.6.tar.xz
69b014782ec157c96b39d09dc3ce25443710b6430c3e4420329afbc141dde21a16a9e310c625039babb839c8b231f8cfe9b640eeef2a7b98b3e9fe51a5a379b0  skip-crq.patch
2006876dd33559a9ee4abe73e7cedc6867c4f480befdfd5fe9e3eca327e291c3cdb12385156c2ba5ab9496dec870b15178249e015363397f1d979ef785906366  tests-certtool.patch
"
